//-------------------------------------------------------//
// Implementation of Math::Angles functions				  //	
//------------------------------------------------------//

namespace Math
{
namespace Angles
{

//---------------------------------------------------
template <typename T>
inline T Sqrt(T _val)
{ 
	return (T)sqrt(_val); 
}

//---------------------------------------------------
template <typename T>
inline T Sin(T _ang)
{ 
	return (T)sin(_ang); 
}

//---------------------------------------------------
template <typename T>
inline T Cos(T _ang)
{ 
	return (T)cos (_ang); 
}

//---------------------------------------------------
template <typename T>
inline T Tan(T _ang)
{ 
	return (T)tan (_ang); 
}

//--------------------------------------------------
template <typename T>
inline void	SinCos(T _ang, T& s_,T& c_)
{ 
	s_= Sin(_ang);  
	c_= Cos(_ang); 
}

//--------------------------------------------------
template <typename T>
inline T ASin(T _val)
{ 
	return (T)asin (_val);  
}

//--------------------------------------------------
template <typename T>
inline T ACos(T _val)
{ 
	return (T)acos (_val); 
}

//--------------------------------------------------
template <typename T>
inline T ATan(T _val)
{ 
	return (T)atan (_val);  
}

//--------------------------------------------------
template <typename T>
inline T ATan2(T _x,T _y)
{ 
	return (T)atan2(_x,_y); 
}
//------------------------------------------------
template <typename T>
inline T PiTimes(T _times)
{
	return ((T)DOUBLE_PI_VALUE)*_times;
}

//------------------------------------------------
template <typename T> 
inline T Deg2Rad(T _deg)
{
	return ( _deg * PiTimes((T)1) ) * (T)(1.0/180.0);
}

//------------------------------------------------
template<typename T>
inline T Rad2Deg(T _rad)
{
	return ((_rad  * (T)180.0) / PiTimes((T)1));
}

//-----------------------------------------------
void CanonizeAngle (float& _fAngle)
{
	_fAngle = fmod(_fAngle, Math::Constants::e2PIf);

	if (_fAngle >  Math::Constants::ePIf) _fAngle -= Math::Constants::e2PIf;
	if (_fAngle < -Math::Constants::ePIf) _fAngle += Math::Constants::e2PIf;
}

} //namespace Utils
} //namespace Math

